﻿<%@ Page Title="填写注册信息" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="RegisterInfo.aspx.cs" Inherits="RegexLib.Web.Views.Member.RegisterInfo" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<form id="RegForm" method="post" action="/Member/RegisterInfoSubmit/">
	<input type="hidden" name="userEmail" value='<%= ViewData["UserEmail"] %>' />
	<table>
		<tr><td>Email地址：</td><td><%= ViewData["UserEmail"] %></td></tr>
		<tr><td>请输入昵称：</td><td><input type="text" name="userNickname" class="input" maxlength="50" /></td></tr>
		<tr><td>请输入密码：</td><td><input type="password" name="userPassword" class="input" maxlength="32" /></td></tr>
		<tr><td>再次输入密码：</td><td><input type="password" name="userPassword2" class="input" maxlength="32" /></td></tr>
		<tr><td>访问路径：</td>
		<td><input type="text" id="UserAk" name="userAccessKey" class="input" maxlength="50" />
		<p class="ds">可以通过<strong>http://regex-lib.net/user/<span id="AkSpan">[访问路径]</span>/</strong>来访问您的个人主页。
		只能使用小写字母和数字。访问路径一旦设定，不能更改。</p></td></tr>
	</table>
</form>
<p><button id="SubmitBtn">确定</button></p>
<p><span id="MsgSpan"></span></p>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ScriptPlaceHolder" runat="server">
<script type="text/javascript">
var c_RegForm;
var c_SubmitBtn;
var c_MsgSpan;
var c_UserAk;
var c_AkSpan;

function GetElements()
{
	c_RegForm = YAHOO.util.Dom.get("RegForm");
	c_SubmitBtn = YAHOO.util.Dom.get("SubmitBtn");
	c_MsgSpan = YAHOO.util.Dom.get("MsgSpan");
	c_UserAk = YAHOO.util.Dom.get("UserAk");
	c_AkSpan = YAHOO.util.Dom.get("AkSpan");
}

function SetMessage(iserr, msg)
{
	if(iserr){	c_MsgSpan.className="err";}
	else{c_MsgSpan.className="suc";}
	
	c_MsgSpan.innerText = msg;
}

function ChAk()
{
	c_AkSpan.innerText = c_UserAk.value;
}

function DoRegister()
{
	c_SubmitBtn.disabled = true;
	
	var callback =
	{
		success: function(o)
		{
			var data = YAHOO.lang.JSON.parse(o.responseText);
			SetMessage(data.IsError, data.Message);
			
			if(!data.IsError)
				c_RegForm.reset();
			else
				c_SubmitBtn.disabled = false;
		},
		failure: function(o)
		{
			SetMessage(true, "未知错误。");
			c_SubmitBtn.disabled = false;
		},
		timeout: 30000
	};
	
	YAHOO.util.Connect.setForm(c_RegForm);
	YAHOO.util.Connect.asyncRequest("POST", "/Member/RegisterInfoSubmit/", callback, null);
}

function init()
{
	GetElements();
	YAHOO.util.Event.addListener(c_SubmitBtn, "click", DoRegister);
	YAHOO.util.Event.addListener(c_UserAk, "change", ChAk);
	YAHOO.util.Event.addListener(c_UserAk, "keyup", ChAk);
}

YAHOO.util.Event.onDOMReady(init);
</script>
</asp:Content>
